package com.umanji.postgis.service;

import java.util.List;

import com.umanji.postgis.domain.Tbbi001;
import com.umanji.usedmarket.domain.UsedProducts;

import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.transaction.annotation.Transactional;

@PreAuthorize("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
public interface PostgisService {

    @PostFilter("filterObject.email == principal.username or hasRole('ROLE_ADMIN')")
    @Transactional(value = "postgis", readOnly = true)
    List<Tbbi001> findAll();

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional(value = "postgis", readOnly = false)
    void persist(Tbbi001 entity);

    @PreFilter("filterObject.email == principal.username")
    @Transactional(value = "postgis", readOnly = false)
    void merge(Tbbi001 entity);

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional(value = "postgis", readOnly = false)
    void remove(Tbbi001 entity);

    @Transactional(value = "postgis", readOnly = true)
    Tbbi001 find(String id);

    @Transactional(value = "postgis", readOnly = true)
    Tbbi001 findByBuildingNo(String no);
}
